﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace SmartMD.DataModel
{
    public class CacheEntity : EntityBase
    {
        private string _id;
        private RecordState _state = RecordState.Normal;
        private bool _deleteFlag;

        [DataMember(Name = "id")]
        public string Id
        {
            get { return _id; }
            set
            {
                if (_id != value)
                {
                    _id = value;
                    OnPropertyChanged("Id");
                }
            }
        }

        /// <summary>
        /// 删除标记: 1(true)- 删除， 0(false/default) - 不删除
        /// </summary>
        [DataMember(Name = "deleteFlag")]
        public bool DeleteFlag
        {
            get
            {
                return _deleteFlag;
            }
            set
            {
                _deleteFlag = value;
                OnPropertyChanged("IsDelete");
            }
        }

        /// <summary>
        /// 本地使用的缓存状态
        /// </summary>
        [DataMember]
        public RecordState State
        {
            get
            {
                if (string.IsNullOrEmpty(this.Id))
                    return RecordState.Added;
                return _state;
            }
            set
            {
                _state = value;
                OnPropertyChanged("State");
            }
        }

        public bool IsSelected { get; set; }
    }
}
